/**
 * This class represents a unique non-stop word in the corpus 
 */
import java.util.HashMap;

public class WordIndexInstance {

	private String word;
	public HashMap matchFiles;
	
	/**
	 * gets the string representation of the word
	 * @return
	 */
	public String getWord()
	{
		return word;
	}
	/**
	 * creates a new instance with the specified word
	 * @param word
	 */
	public WordIndexInstance(String word)	
	{
		matchFiles = new HashMap();
		this.word = word;		
	}
	
	/**
	 * Adds a hit for this word for the particular file instance at the particular line number
	 * @param file
	 * @param lineNumber
	 */
	public void addFileHit(FileIndexInstance file,int lineNumber)
	{
		WordInFileIndexInstance wordInFileIndexInstance = (WordInFileIndexInstance) matchFiles.get(file);
		if(wordInFileIndexInstance==null)
		{
			wordInFileIndexInstance = new WordInFileIndexInstance(file,this);
			matchFiles.put(file,wordInFileIndexInstance);
		}
		wordInFileIndexInstance.addLineNumber(lineNumber);
	}
	
	/**
	 * overrides the hashcode to return the hashcode of the word string
	 */
	public int hashCode(){
		return word.hashCode();		
	}
}
